#ifndef H_EREP_GLOBALSETTINGS
#define H_EREP_GLOBALSETTINGS

#include <QtCore/QtCore>
#include <QtGui/QtGui>
#include <QtWebKit/QtWebKit>

namespace erep
{

struct PersonInfo
{
    PersonInfo( const QString& id );
    bool parseJsonData( const QByteArray& );
    bool read( QTextStream& );
    bool write( QTextStream& );
    
    int _state;
    bool _isMale;
    
    QString _id;
    QString _picture;
    QString _party;
    unsigned int _fights;
    unsigned int _damage;
    unsigned int _lastExp;
    float _skills[4];
    
    // 0 - "level"; 1 - "experience_points"; 2 - "wellness";
    // 3 - "name"; 4 - "date_of_birth"; 5 - date of recording;
    // 6 - "region" and "country"; 7 - no operation time;
    // 8 - "employer", 9 - "employer_id"
    QStringList _mainProperties;
};

struct CompanyInfo
{
    CompanyInfo( const QString& id );
    bool parseJsonData( const QByteArray& );
    bool read( QTextStream& );
    bool write( QTextStream& );
    
    QString _id;
    unsigned int _quality;
    
    // 0 - "name"; 1 - "region" and "country";
    // 2 - "domain"; 3 - "industry"
    QStringList _mainProperties;
};

typedef QMap<QString, PersonInfo*> PersonInfoMap;
typedef QMap<QString, CompanyInfo*> CompanyInfoMap;
extern PersonInfoMap globalCitizens;
extern CompanyInfoMap globalCompanies;

extern int getErepDate( const QString& );
extern int execDialog( const QString& text1, const QString& text2, QMessageBox::Icon icon,
                       const QString& btn1, const QString& btn2=QString(), const QString& btn3=QString() );

extern QString findValue( const QString& src, const QString& key, int* from=0, char sep='\"', char sep2=',' );
extern PersonInfo* findPerson( const QString& );
extern CompanyInfo* findCompany( const QString& );

extern bool openDataFile( const QString& );
extern bool saveDataFile( const QString&, QTableWidget* );

}

#endif
